<?php
/**
 * Abstract class covering base clause functionality
 */
abstract class AbstractSQLClause {
	protected $tblContents = array();
	
	/**
	 * Transforms clause into an array
	 * 
	 * @return array
	 */
	public function toArray() {
		return $this->tblContents;
	}
	
	/**
	 * Transforms clause into a string
	 * 
	 * @abstract
	 * @return string
	 */
	abstract public function toString();
	
	/**
	 * Transforms clause elements into string. If element is encapsulated into an SQLValue, result escapes SQL contained and surrounds with quotes.
	 * 
	 * NOTE: it is mandatory to use prepared statements instead if database server uses Asian character sets (Chinese, Japanese, Korean or Thai), 
	 * otherwise it opens an SQL injection vulnerability
	 * 
	 * @param SQLValue|string $mixInput
	 * @return string
	 */
	public function getValue($mixInput) {
		if($mixInput instanceof SQLValue) {
			return $mixInput->toString();	
		} else {
			return $mixInput;
		}
	}
}